package cn.seaboot.admin.mvc.async;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 线程池配置
 *
 * @author Mr.css
 * @version 2023-02-21 9:31
 */
@Component
@ConfigurationProperties(prefix = "boot-thread-pool")
public class ThreadPoolProperties {

    /**
     * 核心线程数
     *
     * 常备线程，即便没有任务，线程仍然存活着
     */
    private int corePoolSize = 1;

    /**
     * 最大线程数
     *
     * 线程数量上限，决定了数据的吞吐量
     */
    private int maxPoolSize = 5;

    /**
     * 队列大小
     *
     * 数据缓存队列，达到缓存最大值之后，才会开始拒绝新的数据
     */
    private int queueCapacity = 50;

    /**
     * 线程池名称前缀
     */
    private String threadNamePrefix = "sea-";

    public int getCorePoolSize() {
        return corePoolSize;
    }

    public int getMaxPoolSize() {
        return maxPoolSize;
    }

    public int getQueueCapacity() {
        return queueCapacity;
    }

    public String getThreadNamePrefix() {
        return threadNamePrefix;
    }

    public void setCorePoolSize(int corePoolSize) {
        this.corePoolSize = corePoolSize;
    }

    public void setMaxPoolSize(int maxPoolSize) {
        this.maxPoolSize = maxPoolSize;
    }

    public void setQueueCapacity(int queueCapacity) {
        this.queueCapacity = queueCapacity;
    }

    public void setThreadNamePrefix(String threadNamePrefix) {
        this.threadNamePrefix = threadNamePrefix;
    }

    @Override
    public String toString() {
        return "ThreadPoolProperties{" +
                "corePoolSize=" + corePoolSize +
                ", maxPoolSize=" + maxPoolSize +
                ", queueCapacity=" + queueCapacity +
                ", threadNamePrefix='" + threadNamePrefix + '\'' +
                '}';
    }
}
